package customview.ike.com.customviewproject;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import java.util.ArrayList;
import java.util.List;

import customview.ike.com.customviewproject.widget.slidelayout.SlideRecyclerView;
import customview.ike.com.customviewproject.widget.slidelayout.SlideViewLayout;

/**
 * Created by Administrator on 2017/12/4.
 */

public class SlideActivity extends AppCompatActivity {
    private String Tag="SlideActivity";
    private SlideRecyclerView slideRecyclerView;
    private List<String> data=new ArrayList<>();
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_slide);
        slideRecyclerView= (SlideRecyclerView) findViewById(R.id.lv);
        for (int i = 0; i < 30; i++) {
            data.add("我是数据:"+i);
        }
        LinearLayoutManager manager=new LinearLayoutManager(this);
        manager.setOrientation(LinearLayoutManager.VERTICAL);
        slideRecyclerView.setLayoutManager(manager);
        slideRecyclerView.setAdapter(new MyRecycleAdpter());
     
    }
    class MyRecycleAdpter extends RecyclerView.Adapter{

        @Override
        public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
            return new ViewHolder(View.inflate(SlideActivity.this,R.layout.layout_slide,null));
        }

        @Override
        public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
            ViewHolder vh= (ViewHolder) holder;
            vh.tv_content.setText(data.get(position));
            vh.slide_layout.setOnMenuTabOnclickListener(new SlideViewLayout.MenuTabOnclickListener() {
                @Override
                public Void leftClick() {
                    Log.e(Tag,"点击了左边");
                    return null;
                }

                @Override
                public Void rightClick() {
                    Log.e(Tag,"点击了右边");
                    return null;
                }
            });
        }

        @Override
        public int getItemCount() {
            return data.size();
        }
        class ViewHolder extends RecyclerView.ViewHolder{
            private TextView tv_content;
            private SlideViewLayout slide_layout;
            public ViewHolder(View itemView) {
                super(itemView);
                tv_content= (TextView) itemView.findViewById(R.id.tv_content);
                slide_layout= (SlideViewLayout) itemView.findViewById(R.id.slide_layout);
            }
        }
    }
    
}
